package cn.myit.controller;

import cn.myit.domain.Login;
import cn.myit.excption.myexcption;
import cn.myit.service.ILoginService;
import cn.myit.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @PostMapping("/user")
    public R userlogin(@RequestBody Login login){
        try {
            String uuid = loginService.login(login);
            return R.ok("登录成功",uuid);
        } catch (myexcption e) {
            return R.fail(e.getMessage());
        }catch (Exception e){
            return R.fail("系统错误，联系工作人员");
        }
    }
}
